﻿// FMToolbarView.cpp : implementation file
//

#include "stdafx.h"
#include "FMToolbarView.h"
#include "my_def.h"

#include "user.h"// DT_MODIF...
#include "..\ErrorMgt\FMTrace.h"
#include "FMToolBarDef.h"
#include "..\fic.prg\chkuser.h"
#include "opt_disp.h"
#include ".\fmtoolbarview.h"

#include "..\maskeditor\FMIDToString.h"
#include "Ordo_Constantes.h"

#include "FMvwRes.h"
#include "..\include.win\spltddad.h"
#include "profil.h"
#include "select.h"
#include "..\MiscTools\CommonFunctions.h"


FMTRCDOMAIN_DECLARE(Framework);


#define FM_EDIT_MIN_WIDTH			90
#define FM_CHAR_WIDTH				9

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// /------------------------------------------------------------
// | FMTHClass
// |
// | Class Name		: CBaseToolbarView
// | Inherited from : CFormView
// | Created By     : sylvain
// | Creation Date  : Friday, September 03, 2003
// |
// | Purpose        : Container of a CFMNavigationCtrl (+its CFMBitmapButton) and of a toolbar
// |					Toolbar commands are handled by CMyView first, then by the child frame (see OnCmdMsg)
// |					Toolbar behaves as if buttons were clicked in CMyView and as if toolbar belonged to CMainframe
// | How to use		: In OnInitialUpdate, once val_screen is allocated, call SendMessageToToolbarView(FM_UPDATE_SCREEN,(WPARAM) val_screen);
// |					Fmedit notifies its parent from messages (prev, next,...) by sending FM_MSG_SET_DATA message (screen may then be refreshed)
//  ------------------------------------------------------------


/////////////////////////////////////////////////////////////////////////////
// CBaseToolbarView

IMPLEMENT_DYNCREATE(CBaseToolbarView, CFormView)

CBaseToolbarView::CBaseToolbarView()
	: CFormView(CBaseToolbarView::IDD),val_screen(NULL),m_bNavigationAlwaysDisable(false)
{
	//{{AFX_DATA_INIT(CBaseToolbarView)
	m_szKey = _T("");
	//}}AFX_DATA_INIT
	m_bEditHidden=TRUE;// will become false at the first SetData
	m_aViewPreviousFocus=NULL;
	m_bViewDestroyed=FALSE;
	switch(CurrentUserThemeStyle())
	{
		case FM_THEME_OFFICE2007_SILVER:
			m_editKey.SetStyle(2);
			break;
	}	
	SetThemeColor(MyAfxGetMainWnd()->m_FMXpTheme.GetFMToolBarViewBkgColor());
	m_pParaImp = NULL;
}

CBaseToolbarView::~CBaseToolbarView()
{
}

void CBaseToolbarView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CBaseToolbarView)
	DDX_Control(pDX, IDC_EDIT_Key , m_editKey);
	DDX_Text(pDX, IDC_EDIT_Key , m_szKey);
	DDX_Control(pDX, IDC_STATIC_TB1, m_ctrlTB1Holder);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CBaseToolbarView, CFormView)
	//{{AFX_MSG_MAP(CBaseToolbarView)
	ON_WM_SETFOCUS()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
	ON_MESSAGE(FM_UPDATE_SCREEN,OnUpdateScreen)
	ON_MESSAGE(FM_MSG_UPDATE_SELEDIT,OnUpdateSelEdit)
	ON_MESSAGE(FM_MSG_LET_FOCUS_IN_EDIT,OnMsgLetFocusInEdit)
	ON_MESSAGE(FM_UPDATE_CMD_UI,OnMessageUpdateCmdUI)
	ON_MESSAGE(FM_ALWAYS_DISABLE_NAVIGATION,OnMessageAlwaysDisableNavigation)
	ON_MESSAGE(FM_MSG_AFTER_INITIAL_UPDATE,OnMessageAfterInitialUpdate)
	ON_CBN_SELCHANGE(IDC_COMBO_DefaultSel, OnSelchangeComboDefaultSel)
	ON_WM_CTLCOLOR()
	ON_WM_SIZE()
	ON_WM_MOUSEACTIVATE()
END_MESSAGE_MAP()

BEGIN_EVENTSINK_MAP(CBaseToolbarView, CFormView)
	ON_EVENT(CBaseToolbarView, IDC_EDIT_Key, 1, CBaseToolbarView::OnNavigationFinish, VTS_NONE)
	ON_EVENT(CBaseToolbarView, IDC_EDIT_Key, 2, CBaseToolbarView::OnNavigationFinish, VTS_NONE)
	ON_EVENT(CBaseToolbarView, IDC_EDIT_Key, 3, CBaseToolbarView::OnNavigationFinish, VTS_NONE)
	ON_EVENT(CBaseToolbarView, IDC_EDIT_Key, 4, CBaseToolbarView::OnNavigationFinish, VTS_NONE)
	ON_EVENT(CBaseToolbarView, IDC_EDIT_Key, 5, CBaseToolbarView::OnNavigationFinish, VTS_NONE)
	ON_EVENT(CBaseToolbarView, IDC_EDIT_Key, 6, CBaseToolbarView::OnNavigationFinish, VTS_NONE)
	ON_EVENT(CBaseToolbarView, IDC_EDIT_Key, 7, CBaseToolbarView::OnNavigationFinish, VTS_NONE)
	ON_EVENT(CBaseToolbarView, IDC_EDIT_Key, 9, CBaseToolbarView::OnEditGetFocus, VTS_NONE)
	ON_EVENT(CBaseToolbarView, IDC_EDIT_Key, 10, CBaseToolbarView::OnEditLostFocus, VTS_NONE)
END_EVENTSINK_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBaseToolbarView diagnostics

#ifdef _DEBUG
void CBaseToolbarView::AssertValid() const
{
	CFormView::AssertValid();
}

void CBaseToolbarView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CBaseToolbarView message handlers
#define FM_NEW_TOOLBAR_MARGIN 8
void CBaseToolbarView::OnInitialUpdate()
{
	WINDOWPLACEMENT wndPlmnt;
	CFormView::OnInitialUpdate();
	
	m_editKey.SetBackColor(MyAfxGetMainWnd()->m_FMXpTheme.GetFmEditBkgColor());
	UpdateData(FALSE);// init controls
	if(val_screen)
		m_editKey.SetValScreen(val_screen);
	SetData();
	// remove scrollbars
	SetScrollSizes(MM_TEXT,CSize(0,0));
	CreateToolbar();
	ShowToolbar(MyAfxGetMainWnd()->GetToolbarType());

	if (MyAfxGetMainWnd()->GetToolbarType() == TOOLBAR_FOR_SELECT_WITH_BACK_AND_PREDEF_SEL)
	{
		AdjustSelectionScreen();
	}

	m_ctrlTB1Holder.GetWindowPlacement(&wndPlmnt);
	m_wndToolBar.GetToolBarCtrl().SetWindowPlacement(&wndPlmnt);
	CRect rectView, rectWindow;
	GetWindowRect(&rectView);
	m_wndToolBar.GetWindowRect(&rectWindow);
	m_wndToolBar.SetWindowPos(NULL, 0, 0, rectView.Width()-rectWindow.left+rectView.left-FM_NEW_TOOLBAR_MARGIN, rectWindow.Height(), SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);

	
}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: CreateToolbar
// |
// | Return Type: void
// |
// | Parameters:  ()
// |
// | Purpose: construct the toolbar object
// |
//  ------------------------------------------------------------
void CBaseToolbarView::CreateToolbar()
{
//		DWORD dwStyle = WS_CHILD;

	int nToolBarID = IDB_TOOLBAR_VIEW_2003;

	//If BPP is less than 16, load old toolbar
	if(FMGetMainFrame()->m_FMXpTheme.m_b256ColorsMode)
		nToolBarID = IDR_PRODFRAME;

	if (
		!m_wndToolBar.CreateEx(this, TBSTYLE_AUTOSIZE|TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
				| CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0, 0, 0, 0),ID_PRODBAR)
			|| !m_wndToolBar.LoadHiColor(MAKEINTRESOURCE(nToolBarID))
			)
	{
		FMTRACE(Framework, 0, _T("m_wndToolBar.Create fails in CBaseToolbarView::CreateToolbar"));
							return;      // fail to create
	}
}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: AdjustSelectionScreen
// |
// | Return Type: void
// |
// | Parameters:  ()
// |
// | Purpose: adjust the position of dialog item in selection screen
// |
//  ------------------------------------------------------------

void CBaseToolbarView::AdjustSelectionScreen()
{
	CRect rectClient; 
	GetDlgItem(IDC_EDIT_Key)->GetWindowRect(rectClient); 
	ScreenToClient(rectClient);
	GetDlgItem(IDC_EDIT_Key)->SetWindowPos(NULL,rectClient.left+260,rectClient.top,0,0,SWP_NOZORDER|SWP_NOSIZE);

	GetDlgItem(IDC_STATIC_TB1)->GetWindowRect(rectClient); 
	ScreenToClient(rectClient);
	GetDlgItem(IDC_STATIC_TB1)->SetWindowPos(NULL,rectClient.left+260,rectClient.top,0,0,SWP_NOZORDER|SWP_NOSIZE);

	GetDlgItem(IDC_STATIC_DefaultSel)->GetWindowRect(rectClient); 
	ScreenToClient(rectClient);
	GetDlgItem(IDC_STATIC_DefaultSel)->SetWindowPos(NULL,rectClient.left-870,rectClient.top,0,0,SWP_NOZORDER|SWP_NOSIZE);

	GetDlgItem(IDC_COMBO_DefaultSel)->GetWindowRect(rectClient); 
	ScreenToClient(rectClient);
	GetDlgItem(IDC_COMBO_DefaultSel)->SetWindowPos(NULL,rectClient.left-870,rectClient.top,0,0,SWP_NOZORDER|SWP_NOSIZE);

	GetDlgItem(IDC_STATIC_DefaultSel)->ShowWindow(SW_SHOW);
	GetDlgItem(IDC_STATIC_DefaultSel)->SetWindowText(FM_STATIC_LOCALIZED_MSG(ID_FMMSG_PREDEFINEDSELECTION));
	GetDlgItem(IDC_COMBO_DefaultSel)->ShowWindow(SW_SHOW);

}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: ShowToolbar
// |
// | Return Type: void
// |
// | Parameters:  (int nToolbarType)
// |
// | Purpose: Loads the toolbar
// |
//  ------------------------------------------------------------
void CBaseToolbarView::ShowToolbar(int nIDToolbar)
{/// STANDARD TOOLBAR
	int lnButtonIndex;// used for DDAD
	int iNbButtons;
	CMyMDIChildWnd *lParentFrame=(CMyMDIChildWnd *) GetParentFrame();
	int nMenuID=lParentFrame->GetMyMenuID();
	bool bIsVisibleButton;

	int IsVisibleEditDRP=IsShortcutVisible(SHORTCUT_PLANNING);
	int IsVisibleCalibModels=IsShortcutVisible(SHORTCUT_FORECAST);
	int IsVisibleShipmentProfile = IsShortcutVisible(SHORTCUT_SHIPMENT_PROFILE);
	int IsVisiblePromoMasterFile = IsShortcutVisible(SHORTCUT_SHIPMENT_PROMO_MASTER_FILE);
	int IsVisibleDDAComment = 0;
	if(m_pParaImp)
		IsVisibleDDAComment = !m_pParaImp->m_bNodeAttEdit;
	int iChangePassword = 0;

	int iCanSendWebURL = CanSendWebURLEmail(nMenuID);
	int iCanSaveGridLayout = CanSaveGridLayout(nMenuID);
	int iDnaDiagram = (nMenuID == ID_DNA_REPORT_DIRECT_ELEMENT ||  nMenuID == ID_DNA_REPORT_DIRECT_AGGREGATE || (nMenuID >= ID_PERSO_DNA_D_DEB && nMenuID <= ID_PERSO_DNA_A_FIN)) ? 1 : 0;
	int iSendMailinDDA = iDnaDiagram==1? 0 : 1;
	int iLineAnalyzer = (nMenuID == ID_ANALYZER_LINE_DIRECT_ELEMENT ||  nMenuID == ID_ANALYZER_LINE_DIRECT_AGGREGATE) ? 1 : 0;
	int iPromoAnalyzer = (nMenuID == ID_PROMO_ANALYZE)  ? 1 : 0;

	int iAssociatedDDA = GetBTCountForCalibrateDDA(nIDToolbar);
	int iHealthMonitor = Des_Param_Modelisation.m_sHealthMonitor? 2 : 0;
		
	short lnisSheduling = 0;
	if(((O_func_option & O_SCHEDULE) == O_SCHEDULE)) {
		lnisSheduling = 1;
	}

// Liste des toolbars faisant appel aux icones ordo
	switch (nIDToolbar) {

		case TOOLBAR_FOR_SCHEDULING:
			m_wndToolBar.LoadToolBar(IDB_BMP_TOOLBAR_ORDO);
			break;
	}

	lnButtonIndex = 0;
	switch(nIDToolbar){
	case TOOLBAR_FOR_PROD:
		if(nMenuID == ID_CONFIG_SPECIFYUSERSYLVAIN && g_oFMRDMConfig.GetUsePassword())
			iChangePassword = 1;
		iNbButtons = 10 + iChangePassword;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REFRESH, TBBS_BUTTON, 36);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CREATE, TBBS_BUTTON, 3);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DELETE, TBBS_BUTTON, 4);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CHGKEY, TBBS_BUTTON, 20);
		if(iChangePassword)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CHANGE_PASSWORD, TBBS_BUTTON, 50);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DUPLICATE, TBBS_BUTTON, 29);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);

		break;
	case TOOLBAR_FOR_FORECAST:
		iNbButtons = 16 + IsVisibleEditDRP + iHealthMonitor + iAssociatedDDA;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,	TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_F2, TBBS_BUTTON, 16);
		if(IsVisibleEditDRP)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHFT_F3, TBBS_BUTTON, 18);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,	TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FORECASTTOOLBAR_GRAPH_CHECKBOX, TBBS_BUTTON, 46);//show/hide graph dock
		if (iHealthMonitor)
		{
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FORECASTTOOLBAR_HEALTH_MONITOR, TBBS_BUTTON, 59); //show/hide season dock
		}
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FORECASTTOOLBAR_SEASON_CHECKBOX, TBBS_BUTTON, 45); //show/hide season dock
		if(iAssociatedDDA)
		{
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FORECASTTOOLBAR_DDADATA_CHECKBOX, TBBS_BUTTON, 44); //show/hide spreadsheet dock  
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FCSTTOOL_DDAGRAPH_CHECKBOX, TBBS_BUTTON, 53);//show/hide dda graph dock
		}	
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,	TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_1,		TBBS_BUTTON|TBBS_CHECKBOX, 7);//parameter full screen
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_3, TBBS_BUTTON, 8); //graph full screen 
		if (iHealthMonitor)
		{
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FCSTTOOL_HEALTH_MONITOR_FULLSCREEN, TBBS_BUTTON, 60);//season full screen
		}
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FCSTTOOL_SEASON_FULLSCREEN, TBBS_BUTTON, 47);//season full screen
		if(iAssociatedDDA)
		{
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FCSTTOOL_DDADATA_FULLSCREEN, TBBS_BUTTON, 9);//spreadsheet full screen 
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FCSTTOOL_DDAGRAPH_FULLSCREEN, TBBS_BUTTON, 54);//dda graph full screen 
		}
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FCSTTOOL_RESTORE_LAYOUT, TBBS_BUTTON, 52);//Restore Layout 		
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REGISTRY, TBBS_BUTTON, 23);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,	TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_GRAPH_CALCULATE, TBBS_BUTTON, 10);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);

		break;
	case TOOLBAR_FOR_TS:
		iNbButtons = 13 + IsVisibleCalibModels + IsVisibleEditDRP;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REFRESH, TBBS_BUTTON, 36);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,	TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_F2, TBBS_BUTTON, 16);
		if(IsVisibleCalibModels)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHFT_F2, TBBS_BUTTON, 17);
		if(IsVisibleEditDRP)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHFT_F3, TBBS_BUTTON, 18);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,	TBBS_SEPARATOR,17);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_1,		TBBS_BUTTON|TBBS_CHECKBOX, 7);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_2,		TBBS_BUTTON|TBBS_CHECKBOX, 9);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_3,	TBBS_BUTTON|TBBS_CHECKBOX , 8);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REGISTRY, TBBS_BUTTON, 23);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHOW_HIDE_EMPTY_LINES, TBBS_BUTTON|TBBS_CHECKBOX, 28);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);
		break;
	case TOOLBAR_FOR_TSCREATE:
		iNbButtons = 11 + IsVisibleCalibModels + IsVisibleEditDRP;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CREATE, TBBS_BUTTON, 3);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DELETE, TBBS_BUTTON, 4);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CHGKEY, TBBS_BUTTON, 20);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DUPLICATE, TBBS_BUTTON, 29);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_F2,TBBS_BUTTON, 16);
		if(IsVisibleCalibModels)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHFT_F2,TBBS_BUTTON, 17);
		if(IsVisibleEditDRP)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHFT_F3,TBBS_BUTTON, 18);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);
		break;
	case TOOLBAR_FOR_EDIDRP:
		iNbButtons = 18 + IsVisibleCalibModels + iCanSendWebURL;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_GRAPH_CALCULATE, TBBS_BUTTON, 10);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,	TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_F2, TBBS_BUTTON, 16);
		if(IsVisibleCalibModels)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHFT_F2, TBBS_BUTTON, 17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,	TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_1,		TBBS_BUTTON|TBBS_CHECKBOX, 7);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_2,		TBBS_BUTTON|TBBS_CHECKBOX, 9);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_3,	TBBS_BUTTON|TBBS_CHECKBOX , 8);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REGISTRY,	TBBS_BUTTON, 23);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,	TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FIXCELL, TBBS_BUTTON, 12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REMOVEALLFIXEDCELL,	TBBS_BUTTON, 13);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHOW_HIDE_EMPTY_LINES, TBBS_BUTTON|TBBS_CHECKBOX, 28);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,	TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		if(iCanSendWebURL)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMWEBURL_SENDEMAIL, TBBS_BUTTON, 58);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);		
		break;
	case TOOLBAR_FOR_DDAD :
		iNbButtons = 27 + IsVisibleCalibModels + IsVisibleEditDRP + IsVisibleShipmentProfile + IsVisiblePromoMasterFile + IsVisibleDDAComment*3 + iDnaDiagram + iSendMailinDDA;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_GOTO_DDA, TBBS_BUTTON, 21);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FIND_KEY,TBBS_BUTTON, 6);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FIND_NEXT,TBBS_BUTTON, 5);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE,TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_F2,TBBS_BUTTON, 16);
		if(IsVisibleCalibModels)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHFT_F2,TBBS_BUTTON, 17);
		if(IsVisibleEditDRP)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHFT_F3,TBBS_BUTTON, 18);
		if (IsVisibleShipmentProfile)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_TOOLBAR_PROMO_PROFIL_LIVRAISON,TBBS_BUTTON, 33);
		if(IsVisiblePromoMasterFile)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_TOOLBAR_PROMO_GESTION_PROMO,TBBS_BUTTON, 34);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DEFAULT_LAYOUT,	TBBS_BUTTON, 52); //reset layout
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DDATOOLBAR_NAVIGATE_CHECKBOX, TBBS_BUTTON|TBBS_CHECKBOX, 43);	//show/hide Navigate dock			
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DDATOOLBAR_TABLE_CHECKBOX, TBBS_BUTTON|TBBS_CHECKBOX, 44);       //show/hide Table dock
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DDATOOLBAR_GRAPH_CHECKBOX, TBBS_BUTTON|TBBS_CHECKBOX, 45);       //show/hide Graph dock
		if(iDnaDiagram)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DNATOOLBAR_DIAGRAM_CHECKBOX, TBBS_BUTTON|TBBS_CHECKBOX, 66); 
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		if(IsVisibleDDAComment)
		{
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DDATOOLBAR_COMMENT_CHECKBOX, TBBS_BUTTON|TBBS_CHECKBOX, 55);       //show/hide comment dock
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DDATOOLBAR_COMMENT_OPTION, TBBS_BUTTON, 56);       //comment option dialog
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		}		
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_1,		TBBS_BUTTON|TBBS_CHECKBOX, 24); //navigate full screen
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_2,		TBBS_BUTTON|TBBS_CHECKBOX, 9); //Table full screen
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_3,	TBBS_BUTTON|TBBS_CHECKBOX , 8);  //graph full screen
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REGISTRY,	TBBS_BUTTON, 23);   //save 		
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FIXCELL,TBBS_BUTTON, 12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REMOVEALLFIXEDCELL,TBBS_BUTTON, 13);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++,	ID_SHOW_HIDE_EMPTY_LINES, TBBS_BUTTON|TBBS_CHECKBOX, 28);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++,	ID_SHOW_HIDE_HIDDEN_LINES_BY_DEFAULT, TBBS_BUTTON/*|TBBS_CHECKBOX*/, 38);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++,	ID_DYNAMIC_APPLY_CONDITION, TBBS_BUTTON|TBBS_CHECKBOX, 57);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++,	ID_PRINT, TBBS_BUTTON, 11);
		if(iSendMailinDDA)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMWEBURL_SENDEMAIL, TBBS_BUTTON, 58);		
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_GOTO_ASSOCIATE_DDA, TBBS_BUTTON, 0);				
		break;
	case TOOLBAR_FOR_BILLM:
		iNbButtons = 3;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
	case TOOLBAR_FOR_BILLMINV:
		iNbButtons = 1;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
		//<CF>
	case TOOLBAR_FOR_CLASS_ABC:
		iNbButtons = 3;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RUN, TBBS_BUTTON, 0);
		break;
		//</CF>
	case TOOLBAR_FOR_SELECT:
		iNbButtons = 2;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RUN, TBBS_BUTTON, 31);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
	case TOOLBAR_SAVE_ONLY:
		iNbButtons = 2;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
	case TOOLBAR_SAVE_AND_NEXT:
		iNbButtons = 3;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_GOTO_NEXT, TBBS_BUTTON, 0);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
	case TOOLBAR_SAVE_AND_RUN:
		iNbButtons = 3;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RUN, TBBS_BUTTON, 31);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
	case TOOLBAR_FOR_SELECT_WITH_BACK:
	case TOOLBAR_FOR_SELECT_WITH_BACK_AND_PREDEF_SEL:
		bIsVisibleButton=(!IsTemplateDefinitionInvisible(nMenuID));// back button is hidden if user can't access through menus
		if(bIsVisibleButton)
			iNbButtons = 3;
		else 
			iNbButtons = 2;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		if(bIsVisibleButton)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_GOTO_BACK, TBBS_BUTTON, 1);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RUN, TBBS_BUTTON, 31);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
	case TOOLBAR_FOR_CALDRP:
		iNbButtons = 4;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_GOTO_BACK, TBBS_BUTTON, 1);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RUN, TBBS_BUTTON, 31);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
	case TOOLBAR_FOR_HIER:
		iNbButtons = 8;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_F2,TBBS_BUTTON, 16);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FIND_KEY,TBBS_BUTTON|TBBS_CHECKBOX, 6);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FIND_NEXT,TBBS_BUTTON, 5);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BALANCE,TBBS_BUTTON, 22);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_GRAPH_CALCULATE, TBBS_BUTTON, 10);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT_HIER, TBBS_BUTTON, 11);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REFRESH, TBBS_BUTTON, 36);
		break;
	case TOOLBAR_DUPLICATE:
		iNbButtons = 9;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CREATE, TBBS_BUTTON, 3);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DELETE, TBBS_BUTTON, 4);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CHGKEY, TBBS_BUTTON, 20);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DUPLICATE, TBBS_BUTTON, 29);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);
		break;
	case TOOLBAR_FOR_PROMO_CALCULATE:
		iNbButtons = 7;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_F2, TBBS_BUTTON, 16);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_GRAPH_CALCULATE, TBBS_BUTTON, 10);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
	case TOOLBAR_FOR_PROMO_RUN:
		iNbButtons = 2;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RUN, TBBS_BUTTON, 31);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
		//<CF>
	case TOOLBAR_FOR_PROMO:
		iNbButtons = 19;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REFRESH, TBBS_BUTTON, 36);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_GRAPH_CALCULATE, TBBS_BUTTON, 10);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_F2, TBBS_BUTTON, 16);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ANALYZER_SHORTCUT, TBBS_BUTTON, 39);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_LINEANALYZER_SHORTCUT, TBBS_BUTTON, 42);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CUBE_SHORTCUT, TBBS_BUTTON, 40);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_XLS_SHORTCUT, TBBS_BUTTON, 41);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CREATE, TBBS_BUTTON, 3);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DELETE, TBBS_BUTTON, 4);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CHGKEY, TBBS_BUTTON, 20);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DUPLICATE, TBBS_BUTTON, 29);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMWEBURL_SENDEMAIL, TBBS_BUTTON, 58);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);		
		break;
		//</CF>
	case TOOLBAR_FOR_PLANNING:
		iNbButtons = 8 + lnisSheduling;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CREATE, TBBS_BUTTON, 3);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DELETE, TBBS_BUTTON, 4);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CHGKEY, TBBS_BUTTON, 20);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DUPLICATE, TBBS_BUTTON, 29);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);
		break;
	case TOOLBAR_FOR_PLANNING_CALCULATION:
		iNbButtons = 10 + lnisSheduling;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_OPTIM_CALCULATION, TBBS_BUTTON, 10);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CREATE, TBBS_BUTTON, 3);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DELETE, TBBS_BUTTON, 4);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CHGKEY, TBBS_BUTTON, 20);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DUPLICATE, TBBS_BUTTON, 29);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);
		break;
	case TOOLBAR_FOR_SCHEDULING_RULE:
		iNbButtons = 10;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ORDO_CALCULATION, TBBS_BUTTON, 10);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CREATE, TBBS_BUTTON, 3);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DELETE, TBBS_BUTTON, 4);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CHGKEY, TBBS_BUTTON, 20);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DUPLICATE, TBBS_BUTTON, 29);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
#pragma message( __FILE__  "(538): TODO: a voir avec JPC ")
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);
		break;
	case TOOLBAR_FOR_SCHEDULING:
		{
		struct OPTIONS_ORDO	lOptionsOrdo;
		lOptionsOrdo.LoadDB();

		iNbButtons = 24;
		if (lOptionsOrdo.TypeRealiseGlobal == ORDO_REALISE_MANUEL)
			iNbButtons--;
		if (lOptionsOrdo.m_bMovingOrdersWithoutAvailablePlace == 0)
			iNbButtons--;

		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE,						TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CANCEL_ORDO,					TBBS_BUTTON, 12);
		if (lOptionsOrdo.TypeRealiseGlobal != ORDO_REALISE_MANUEL) {
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REFRESH_REALIZED_ORDO,		TBBS_BUTTON, 17);
		}
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_DATA_TO_FIX,		TBBS_BUTTON, 3);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,0);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ORDO_CALCULATION,			TBBS_BUTTON, 8);
//		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ORDO_CALCULATION_2,			TBBS_BUTTON, 8);
//		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ORDO_RECALCULATION,			TBBS_BUTTON, 8);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ORDO_APPLY_REALIZED,			TBBS_BUTTON, 18);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,0);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_SHOW_LAST_SAVE,	TBBS_BUTTON, 0);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_SHOW_LAST_FIXED,	TBBS_BUTTON, 1);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_SHOW_REALIZED,	TBBS_BUTTON, 16);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,0);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_GLOBAL_VIEW,		TBBS_BUTTON, 4);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_FAMILY_VIEW,		TBBS_BUTTON, 5);
//		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_SHOW_DELAY,		TBBS_BUTTON, 5);
//		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_VIEW_REALIZED,	TBBS_BUTTON, 5);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_DEFAULT_VIEW,	TBBS_BUTTON, 6);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,0);

//		if (lOptionsOrdo.FrozenScheduling) {
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ORDO_FROZEN_LINE,		TBBS_BUTTON, 13);
//		}
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_OPTIMAL_SEQUENCE,TBBS_BUTTON|TBBS_CHECKBOX,14);
		if (lOptionsOrdo.m_bMovingOrdersWithoutAvailablePlace)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_MOVE_IN_ANY_CASE,TBBS_BUTTON|TBBS_CHECKBOX,19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_BUTTON_ORDO_ASK_VALIDATION,	TBBS_BUTTON|TBBS_CHECKBOX,15);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,0);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REGISTRY,					TBBS_BUTTON,11);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,					TBBS_SEPARATOR,0);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT,						TBBS_BUTTON, 9);
		break;
		}
	case TOOLBAR_FOR_SCHEDULING_FICHE:
		iNbButtons = 4;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REGISTRY, TBBS_BUTTON,23);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
	case TOOLBAR_FOR_SCHEDULING_SETUP:
		iNbButtons = 3;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		break;
	case TOOLBAR_FOR_PERSO:
		iNbButtons = 7;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_EDIT_CUT, TBBS_BUTTON, 25);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_EDIT_COPY, TBBS_BUTTON, 26);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_EDIT_PASTE, TBBS_BUTTON, 27);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON,11);
		break;

	case TOOLBAR_STRUCT_REPORT:
		iNbButtons = 19;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RUN, TBBS_BUTTON, 31);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REFRESH, TBBS_BUTTON, 36);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CREATE, TBBS_BUTTON, 3);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DELETE, TBBS_BUTTON, 4);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CHGKEY, TBBS_BUTTON, 20);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DUPLICATE, TBBS_BUTTON, 29);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_STRUCT_REPORT_AVAILABLE_FIELDS_CHECKBOX, TBBS_BUTTON|TBBS_CHECKBOX, 68);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_STRUCT_REPORT_RESULT_GRID_CHECKBOX, TBBS_BUTTON|TBBS_CHECKBOX, 69);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_STRUCT_REPORT_PERIMETER_CHECKBOX, TBBS_BUTTON|TBBS_CHECKBOX, 51); 
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FCSTTOOL_RESTORE_LAYOUT, TBBS_BUTTON, 52);//Restore Layout 		
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REGISTRY, TBBS_BUTTON, 23);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);		
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_EXPORT_TO_FILE, TBBS_BUTTON, 30);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);

		
		break;

	case TOOLBAR_REPORT_DEF:
		iNbButtons = 14+iCanSendWebURL;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REFRESH, TBBS_BUTTON, 36);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CREATE, TBBS_BUTTON, 3);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DELETE, TBBS_BUTTON, 4);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CHGKEY, TBBS_BUTTON, 20);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DUPLICATE, TBBS_BUTTON, 29);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_EXPORT_TO_FILE, TBBS_BUTTON, 30);
		if(iCanSendWebURL)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMWEBURL_SENDEMAIL, TBBS_BUTTON, 58);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RCDINFO, TBBS_BUTTON, 37);		
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_GOTO_NEXT, TBBS_BUTTON, 0);		
		break;
	case TOOLBAR_FOR_ANALYZER:
		iNbButtons = 17+5*iCanSaveGridLayout+IsVisiblePromoMasterFile+IsVisibleShipmentProfile;

		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RUN, TBBS_BUTTON, 31);
		if(IsVisiblePromoMasterFile) // add the Promotion Management Shortcut if the license gives the rights for Promo.
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_TOOLBAR_PROMO_GESTION_PROMO, TBBS_BUTTON, 34);
		
		if(IsVisibleShipmentProfile)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_TOOLBAR_PROMO_PROFIL_LIVRAISON,TBBS_BUTTON, 33);
		
//		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REGISTRY,	TBBS_BUTTON, 23);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHOW_TOP_VALUES_CONFIG, TBBS_BUTTON|TBBS_CHECKBOX, 48);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHOW_LAYOUT_CONFIG, TBBS_BUTTON|TBBS_CHECKBOX, 49);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHOW_COPY_CONFIG, TBBS_BUTTON|TBBS_CHECKBOX, 61);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHOW_CUSTOM_GROUP_CONFIG, TBBS_BUTTON|TBBS_CHECKBOX, 51);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DNATOOLBAR_ANALYZER_TS_FILTER, TBBS_BUTTON, 67);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);

		if (iCanSaveGridLayout)
		{
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMXTRAPIVOTGRID_SAVE_LAYOUT,	TBBS_BUTTON, 62);
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMXTRAPIVOTGRID_SAVE_LAYOUT_AS,	TBBS_BUTTON, 63);
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMXTRAPIVOTGRID_LOAD_LAYOUT,	TBBS_BUTTON, 64);
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMXTRAPIVOTGRID_DEL_LAYOUT,	TBBS_BUTTON, 65);
		}

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DEFAULT_LAYOUT,	TBBS_BUTTON, 52); //reset layout
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DDATOOLBAR_GRAPH_CHECKBOX, TBBS_BUTTON|TBBS_CHECKBOX, 45);       //show/hide Graph dock
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_1,	TBBS_BUTTON|TBBS_CHECKBOX, 7);   //data full screen
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_3,	TBBS_BUTTON|TBBS_CHECKBOX , 8);  //graph full screen

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ENABLE_UPDATE_GRAPH,    TBBS_BUTTON|TBBS_CHECKBOX, 70);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_UPDATE_GRAPH,    TBBS_BUTTON, 71);
		break;
	case TOOLBAR_FOR_ANALYZER_LINE:

		iNbButtons = 20+5*iCanSaveGridLayout+IsVisiblePromoMasterFile+IsVisibleShipmentProfile+iLineAnalyzer + iPromoAnalyzer;

		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RUN, TBBS_BUTTON, 31);
		if(IsVisiblePromoMasterFile) // add the Promotion Management Shortcut if the license gives the rights for Promo.
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_TOOLBAR_PROMO_GESTION_PROMO, TBBS_BUTTON, 34);
		
		if(IsVisibleShipmentProfile)
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_TOOLBAR_PROMO_PROFIL_LIVRAISON,TBBS_BUTTON, 33);
		
		if (iPromoAnalyzer)
		{
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REGISTRY,	TBBS_BUTTON, 23);
		}

		if (iLineAnalyzer)
		{
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHOW_TOP_VALUES_CONFIG, TBBS_BUTTON|TBBS_CHECKBOX, 48);
		}
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHOW_LAYOUT_CONFIG, TBBS_BUTTON|TBBS_CHECKBOX, 49);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHOW_COPY_CONFIG, TBBS_BUTTON|TBBS_CHECKBOX, 61);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SHOW_CUSTOM_GROUP_CONFIG, TBBS_BUTTON|TBBS_CHECKBOX, 51);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DNATOOLBAR_ANALYZER_TS_FILTER, TBBS_BUTTON, 67);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);
		
		if (iCanSaveGridLayout)
		{
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMXTRAPIVOTGRID_SAVE_LAYOUT,	TBBS_BUTTON, 62);
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMXTRAPIVOTGRID_SAVE_LAYOUT_AS,	TBBS_BUTTON, 63);
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMXTRAPIVOTGRID_LOAD_LAYOUT,	TBBS_BUTTON, 64);
			m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FMXTRAPIVOTGRID_DEL_LAYOUT,	TBBS_BUTTON, 65);
		}

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DEFAULT_LAYOUT,	TBBS_BUTTON, 52); //reset layout
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DDATOOLBAR_GRAPH_CHECKBOX, TBBS_BUTTON|TBBS_CHECKBOX, 45);       //show/hide Graph dock
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_1,	TBBS_BUTTON|TBBS_CHECKBOX, 7);   //data full screen
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_3,	TBBS_BUTTON|TBBS_CHECKBOX , 8);  //graph full screen

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FIXCELL,TBBS_BUTTON, 12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REMOVEALLFIXEDCELL,TBBS_BUTTON, 13);

		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ENABLE_UPDATE_GRAPH,    TBBS_BUTTON|TBBS_CHECKBOX, 70);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_UPDATE_GRAPH,    TBBS_BUTTON, 71);
		break;
	case TOOLBAR_FOR_PROMO_PLANNING :
		iNbButtons = 13;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RUN, TBBS_BUTTON, 31);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_TOOLBAR_PROMO_GESTION_PROMO,TBBS_BUTTON, 34);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REGISTRY,	TBBS_BUTTON, 23);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_PRINT, TBBS_BUTTON, 11);


		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DEFAULT_LAYOUT,	TBBS_BUTTON, 52); //reset layout
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DDATOOLBAR_GRAPH_CHECKBOX, TBBS_BUTTON|TBBS_CHECKBOX, 45);       //show/hide Graph dock
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR,		TBBS_SEPARATOR,17);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_1,	TBBS_BUTTON|TBBS_CHECKBOX, 7);   //data full screen
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SPLIT_3,	TBBS_BUTTON|TBBS_CHECKBOX , 8);  //graph full screen


		break;
	case TOOLBAR_FOR_PLANNING_CT_TYPE:
		iNbButtons = 10;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE, TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_RUN, TBBS_BUTTON, 31);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CREATE, TBBS_BUTTON, 3);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DELETE, TBBS_BUTTON, 4);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_CHGKEY, TBBS_BUTTON, 20);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_DUPLICATE, TBBS_BUTTON, 29);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SEPARATOR, TBBS_SEPARATOR,12);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_FCSTTOOL_RESTORE_LAYOUT, TBBS_BUTTON, 52);//Restore Layout 
		break;
	case TOOLBAR_FOR_DDS :
		iNbButtons = 4;
		m_wndToolBar.SetButtons(NULL,iNbButtons);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_SAVE,TBBS_BUTTON, 2);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_ESC, TBBS_BUTTON, 19);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++, ID_REFRESH, TBBS_BUTTON, 36);
		m_wndToolBar.SetButtonInfo(lnButtonIndex++,	ID_PRINT, TBBS_BUTTON, 11);
		break;
	}

	m_wndToolBar.Invalidate();
//		RecalcLayout();
	m_wndToolBar.ShowWindow(SW_SHOW);
}

void CBaseToolbarView::SetValScreen(PTECR val_ecr)
{
	if(val_ecr)
	{
		val_screen=val_ecr;
		m_editKey.SetValScreen(val_ecr);
	}
}

void CBaseToolbarView::SetData()
{
	if(val_screen)
		m_szKey=val_screen->cle;
	UpdateData(FALSE);
}
void CBaseToolbarView::InitComboBox()
{
	if (m_pParaImp)
	{
		int nMax = m_pParaImp->m_oSelConfigureArray.GetCount();
		CComboBox* pCombobox = (CComboBox*)GetDlgItem(IDC_COMBO_DefaultSel);
		pCombobox->ResetContent();
		pCombobox->AddString(_T(" "));
		for (int iIndex = 0; iIndex < nMax; iIndex++)
		{
			FMString strCur = m_pParaImp->m_oSelConfigureArray.GetAt(iIndex);
			pCombobox->AddString(strCur);
		}
		CString strProfileKey = FMGetCurrentProfilNameWithDefault(true);
		CString strSelDefault;
		int nIndex = FindStringIndex(m_pParaImp->m_oSelProfileArray, strProfileKey);
		if(nIndex > -1)
		{
			strSelDefault = m_pParaImp->m_oSelConfigureArray.GetAt(nIndex);
		}

		pCombobox->SelectString(-1, strSelDefault);
	}
	UpdateData(FALSE);

}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: *Screen
// |
// | Return Type: LRESULT
// |
// | Parameters:  (WPARAM val_ecr, LPARAM lParam)
// |
// | Purpose: I receive FM_UPDATE_SCREEN message when internal structure has changed and I need to refresh
//  ------------------------------------------------------------
LRESULT CBaseToolbarView::OnUpdateScreen(WPARAM val_ecr, LPARAM lParam)
{
	SetValScreen((PTECR)val_ecr);
	if (lParam != NULL)
	{
		SetParaImp((PTPARAIMP)lParam);
	}
	if(m_bEditHidden && val_screen!=NULL)// we test NULL on val_screen member, not val_ecr parameter
		ShowEdit();
	SetData();
	InitComboBox();
	
	CMyMDIChildWnd *lParentFrame=(CMyMDIChildWnd *) GetParentFrame();
	CWnd *aMyView=lParentFrame->GetMyView();
	if(aMyView)
	{
		aMyView->SendMessage(FM_UPDATE_SCREEN_FOR_VARIANT);
	}
	return 0L;
}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: *Screen
// |
// | Return Type: LRESULT
// |
// | Parameters:  (WPARAM val_ecr, LPARAM lParam)
// |
// | Purpose: I receive FM_UPDATE_SCREEN message when internal structure has changed and I need to refresh
//  ------------------------------------------------------------
LRESULT CBaseToolbarView::OnUpdateSelEdit(WPARAM val_ecr, LPARAM lParam)
{
	SetValScreen((PTECR)val_ecr);
	if(m_bEditHidden && val_screen!=NULL)// we test NULL on val_screen member, not val_ecr parameter
		ShowEdit();
	SetData();
	return 0L;
}
// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: OnSelchangeComboDefaultSel
// |
// | Return Type: void
// |
// | Parameters:  ()
// |
// | Purpose: send message to the selection screen when combbox changes
//  ------------------------------------------------------------
afx_msg void CBaseToolbarView::OnSelchangeComboDefaultSel()
{
	CMyMDIChildWnd *lParentFrame=(CMyMDIChildWnd *) GetParentFrame();
	CWnd *aMyView=lParentFrame->GetMyView();

	CComboBox* pCombobox = (CComboBox*)GetDlgItem(IDC_COMBO_DefaultSel);
	int nSel = pCombobox->GetCurSel();
	if(aMyView)
	{
		aMyView->SendMessage(FM_MSG_SELCHANGE_DEFAULTSEL, (WPARAM)nSel);
	}
}
// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: SetInitFocus
// |
// | Return Type: void
// |
// | Parameters:  ()
// |
// | Purpose: sets the focus in the edit
// |
//  ------------------------------------------------------------
void CBaseToolbarView::SetInitFocus()
{
	CMyMDIChildWnd* aParentFrame;
	CView *aWndMyView;

	if(m_editKey.m_hWnd==NULL)
		UpdateData(FALSE);
	if(m_editKey.IsWindowVisible())
	{
		m_editKey.SetFocus();

		/*
		aParentFrame=(CMyMDIChildWnd*) GetParentFrame();
		aParentFrame->SetActiveView(this, false);
		*/
	}
	else
	{
		aParentFrame=(CMyMDIChildWnd*) GetParentFrame();
		/*
		aWndMyView=aParentFrame->GetMyView();
		if(!aWndMyView)// special case for DDA, activate next pane
			aWndMyView=m_aViewPreviousFocus;
		if(aWndMyView)
		{
			aParentFrame->SetActiveView(aWndMyView,FALSE);
			aWndMyView->SetFocus();
			m_aViewPreviousFocus=aWndMyView;
		}
		*/
		aWndMyView = aParentFrame->GetActiveView();
		if(aWndMyView != NULL)
		{
			aWndMyView->SetFocus();
		}
	}
}

BOOL CBaseToolbarView::PreTranslateMessage(MSG* pMsg)
{
	CWnd *wndParent=NULL;

	if (pMsg->message == WM_KEYDOWN)
	{
		if(pMsg->wParam==VK_ESCAPE)
		{	// escape full screen
			if (MyAfxGetMainWnd()->GetFullScreenSize(this, CPoint(0,0)))
				MyAfxGetMainWnd()->EscapeFullScreen();
		}
		if(pMsg->wParam==VK_TAB && !(GetKeyState(VK_CONTROL) & 0x8000))// filter tab but not ctrl-tab
		{
			// trouver la fenêtre focus
			wndParent=GetParentFrame();
			if(wndParent)
			{
				if(GetKeyState(VK_SHIFT) & 0x8000)
					// shift-key is down, activate prev logical control
					wndParent->SendMessage(FM_MSG_SET_PREV_FOCUS,(WPARAM) this);
				else
					wndParent->SendMessage(FM_MSG_SET_NEXT_FOCUS,(WPARAM) this);
				return TRUE;
			}
        }
	}
	return CFormView::PreTranslateMessage(pMsg);
}


// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CFMToolBarViewIdleCallBack
// | Method Name: OnIdle
// |
// | Return Type: void
// |
// | Parameters:  LONG lCount
// |
// | Purpose:
// |
//  ------------------------------------------------------------
void	CFMToolBarViewIdleCallBack::OnIdle(LONG lCount)
{
//		if (m_pFMToolBarView)
//			m_pFMToolBarView->UpdateDialogControls(AfxGetMainWnd(), FALSE);
}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: OnCmdMsg
// |
// | Return Type: BOOL
// |
// | Parameters:  (UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
// |
// | Purpose: Instead of routing toolbar notifications to this view, we first route to CMyView,
// |			then to the frame. As this view is the toolbar parent, commands are normally routed to this view
// |			and never get routed to the child frame. The standard MFC routing has been changed by setting CMyView
// |			as the active view before dealing with OnCMdMsg. We then restore the active view
// |		  When it is more complicated to know which view should handle the command, set GetMyView to NULL and handle
// |			all commands in the CMyMDIChildWnd derived class (GetActiveView() is NULL, then we only look in frame).
// |			See DDA for the latter case : commands got by frame are rerouted to the view supposed to handle the commmand.
// |			After a command, we reset the focus to the previous view so that the buttons act as a real toolbar. The exception
// |			is setting the focus to my CFMNavigationCtrl. In that case, I get the FM_MSG_LET_FOCUS_IN_EDIT message
//  ------------------------------------------------------------
BOOL CBaseToolbarView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
	UINT message=HIWORD(nCode);// handle message==WM_NOTIFY for tooltip notification
	if( nCode==CN_UPDATE_COMMAND_UI // update cmd ui
		|| (message==WM_NOTIFY && nID==0) // tooltip needed
		|| ((nCode==BN_CLICKED)&& NULL==pExtra) // a toolbar button was clicked
		)
	{
		CMyMDIChildWnd *aWndParentFrame;
		CMainFrame* aMainframe;

		aMainframe=MyAfxGetMainWnd();
		aWndParentFrame=(CMyMDIChildWnd *) GetParentFrame();
		if(aWndParentFrame->GetActiveView() == this)
		{
			return CFormView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
		}
		else
		{
			CView* pMyView = aWndParentFrame->GetMyView();
			if(pMyView != NULL)
			{
				if(pMyView->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
					return TRUE;
			}
			return aWndParentFrame->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
		}

		/*
		if(aWndParentFrame!=aMainframe->MDIGetActive() && !aWndParentFrame->m_bFloating)
		{
			return CFormView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
		}

		CView	*aMyView,// delegate view
			*aViewActive;// active view before message processing (needs to be restored for tooltip notification
		CWnd * aWndFocus;

		aMyView=aWndParentFrame->GetMyView();
		aViewActive=aWndParentFrame->GetActiveView();
		// aMyView can be NULL (as in DDA)
		if(IsFocusInFmedit())
			m_aViewPreviousFocus=this;
		
		if(aMyView==NULL)
		{
			aWndFocus=GetFocus();
			if(message==WM_NOTIFY)
			{	// tooltip notification does not call CBaseToolbarView::OnSetFocus()
				// we then must delegate to the view who really owns the focus
				if(this->IsChild(aWndFocus))// must not recurse
					return CFormView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
				else
				{
					aMyView=(CView *) aWndFocus;
					while(aMyView && !aMyView->IsKindOf(RUNTIME_CLASS(CView)))
						aMyView=(CView *) aMyView->GetParent();
				}
			}
			else
				aMyView=m_aViewPreviousFocus;
		}

		//Avoid infinite loop, we should never call OnCmdMsg on the toolbar view here because were are already in it !
		if(aMyView && aMyView->GetSafeHwnd() != this->GetSafeHwnd())
		{
			int nRet;
			HWND hWndParentFrame,hWndMyView;

			// set the active view as myview or previous focus
			FMASSERT_FATAL(aMyView->IsKindOf(RUNTIME_CLASS(CView)) && aWndParentFrame->IsChild(aMyView));
			aWndParentFrame->SetActiveView(aMyView,FALSE);
			// store parent frame m_hWnd. If the command deletes frame, we should do nothing after the cmd
			hWndParentFrame=aWndParentFrame->m_hWnd;
			hWndMyView=aMyView->m_hWnd;
			nRet=aWndParentFrame->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
			// after the command, restore the focus on previous focus. We don't change the focus for tooltip notification
			if(::IsWindow(hWndParentFrame) && ::IsWindow(hWndMyView) &&
				!m_bViewDestroyed && //View can be destroyed from button
				GetForegroundWindow()==aMainframe && // another application may be activated (for example, open excel
				aWndParentFrame==aMainframe->MDIGetActive() &&// command may have opened a new window
				aWndParentFrame->GetActiveView()==aMyView)// command may have changed the active view (we have called SetActiveView(aMyView) before command processing
			{
				if(message==WM_NOTIFY)
				{
					aWndParentFrame->SetActiveView(aViewActive,FALSE);
				}
				else
				{
					if(m_aViewPreviousFocus)
					{	// if focus was not on the CFMNavigationCtrl or its bitmap buttons, set the focus to where it was before
						if(aWndParentFrame->IsChild(m_aViewPreviousFocus))
						{
							aWndParentFrame->SetActiveView(m_aViewPreviousFocus,FALSE);
							aWndFocus=GetFocus();
							//	if focus is already in m_aViewPreviousFocus, we don't SetFocus again (the command may have changed the focus window)
							// test on !aWndFocus prevents from calling IsChild(NULL)
							if(!IsFocusInFmedit() && (!aWndFocus || !m_aViewPreviousFocus->IsChild(aWndFocus)))
								m_aViewPreviousFocus->SetFocus();
						}
					}
				}
			}

			return nRet;
		}	
		else
		{
			// in DDA, FMinfoDlg can have the focus (aWndFocus is not child of a view). 
			// If mouse is over a toolbar button (therefore displaying a tooltip) and we press enter, aMyView is NULL and we return 0 for the WM_NOTIFY message
			FMTRACE(Framework, 2, _T("aMyView==NULL. OnCmdMsg returns 0"));

			return CFormView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
		}
		*/
	}
	return CFormView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: ShowEdit
// |
// | Return Type: void
// |
// | Parameters:  ()
// |
// | Purpose: Show the fmedit which is hidden by default
// |
//  ------------------------------------------------------------
void CBaseToolbarView::ShowEdit()
{
	m_bEditHidden=FALSE;
	if(m_editKey.m_hWnd==NULL)
		UpdateData(FALSE);// init controls if not done yet
	m_editKey.ShowWindow(SW_SHOW);

	//Sometimes, old style fmedit was displayed, force style update here to avoid this
	m_editKey.ForceStyleUpdate();
}

void CBaseToolbarView::OnSetFocus(CWnd* pOldWnd)
{
	CFormView::OnSetFocus(pOldWnd);
	CMyMDIChildWnd *lParentFrame=(CMyMDIChildWnd *) GetParentFrame();
	if(lParentFrame->IsChild(pOldWnd))
	{
		m_aViewPreviousFocus=(CView *) pOldWnd;
		while(m_aViewPreviousFocus && !m_aViewPreviousFocus->IsKindOf(RUNTIME_CLASS(CView)))
			m_aViewPreviousFocus=(CView *) m_aViewPreviousFocus->GetParent();
	}// else this frame is now inactive
	else
	{
		// in forecast, enter a invalid data (so that UpdateData fails) and then click on ID_GRAPH_CALCULATE
		// without setting m_aViewPreviousFocus to NULL, infinite loop of UpdateData error message
		if(lParentFrame==pOldWnd)
			m_aViewPreviousFocus=NULL;
	}
}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: OnMsgLetFocusInEdit
// |
// | Return Type: LRESULT 
// |
// | Parameters:  (PTECR val_ecr, LPARAM lParam)
// |
// | Purpose: I receive FM_MSG_LET_FOCUS_IN_EDIT when focus is set to a CFMBitmapButton or to a CFMNavigationCtrl (main key):mouse click or keyboard
// |			In that case, OnCmdMsg must not change the focus (see OnCmdMsg)
//  ------------------------------------------------------------
LRESULT CBaseToolbarView::OnMsgLetFocusInEdit(WPARAM wParam, LPARAM lParam)
{
	// OBSOLETE message
	//m_aViewPreviousFocus=this;
	return 0L;// return value not tested
}

BOOL CBaseToolbarView::OnTextForTooltip( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{
	return(MyAfxGetMainWnd()->TextForTooltip(id, pNMHDR, pResult));
}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: OnMessageUpdateCmdUI
// |
// | Return Type: LRESULT 
// |
// | Parameters:  (WPARAM wParam // = BOOL true if hyperlink must be enabled
// |				, LPARAM lParam)
// |
// | Purpose: MyView warns that modified state has changed
// |			Enable or disable hyperlink
//  ------------------------------------------------------------
LRESULT CBaseToolbarView::OnMessageUpdateCmdUI(WPARAM wParam, LPARAM lParam)
{
	// myview is in SetModified function. Update Save and cancel buttons in FMToolbar
	UpdateData(FALSE);// init controls
	m_editKey.SetEnableLink(wParam && !m_bNavigationAlwaysDisable);
	return 0L;
}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: OnMessageAlwaysDisableNavigation
// |
// | Return Type: LRESULT 
// |
// | Parameters:  (WPARAM wParam // unused
// |				, LPARAM lParam) // unused
// |
// | Purpose: Navigation buttons are disabled is
// |
//  ------------------------------------------------------------
LRESULT CBaseToolbarView::OnMessageAlwaysDisableNavigation(WPARAM wParam, LPARAM lParam)
{
	m_bNavigationAlwaysDisable=true;
	return 0L;
}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CMyView
// | Method Name: OnMessageAfterInitialUpdate
// |
// | Return Type: LRESULT 
// |
// | Parameters:  (WPARAM wParam, LPARAM lParam)
// |
// | Purpose: message sent by the framework after OnInitialUpdate calls
//  ------------------------------------------------------------
LRESULT CBaseToolbarView::OnMessageAfterInitialUpdate(WPARAM wParam, LPARAM lParam)
{
	WINDOWPLACEMENT wndPlmntToolbar,wndPlmntEdit;

	if(m_bEditHidden)
	{// if edit is not shown, move toolbar to the left
		m_wndToolBar.GetToolBarCtrl().GetWindowPlacement(&wndPlmntToolbar);
		m_editKey.GetWindowPlacement(&wndPlmntEdit);
		wndPlmntToolbar.rcNormalPosition.left=wndPlmntEdit.rcNormalPosition.left;
		m_wndToolBar.GetToolBarCtrl().SetWindowPlacement(&wndPlmntToolbar);
		CRect rectView, rectWindow;
		GetWindowRect(&rectView);
		m_wndToolBar.GetWindowRect(&rectWindow);
		m_wndToolBar.SetWindowPos(NULL, 0, 0, rectView.Width()-rectWindow.left+rectView.left-FM_NEW_TOOLBAR_MARGIN, rectWindow.Height(), SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
	}
	else
	{
		//si la clé à afficher est composée, on modifie fmtoolbarview
		if (val_screen!=NULL)	
		{
			//taille par défaut du fmedit
			m_ctrlTB1Holder.GetWindowPlacement(&wndPlmntToolbar);
			m_wndToolBar.GetToolBarCtrl().SetWindowPlacement(&wndPlmntToolbar);
			CRect rectView, rectWindow;
			GetWindowRect(&rectView);
			m_wndToolBar.GetWindowRect(&rectWindow);
			m_wndToolBar.SetWindowPos(NULL, 0, 0, rectView.Width()-rectWindow.left+rectView.left-FM_NEW_TOOLBAR_MARGIN, rectWindow.Height(), SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
			// ModifyToolBarViewForCompoundKeys() must be called after previous lines (bug with Init prev com on detail level : select screen)
			switch(val_screen->type)
			{
				case RGP:
				case PRS:
				case IND:
				case UNI:
				case BDG:
				case PVT:
				case SEL:
					ModifyToolBarViewForCompoundKeys();
					break;
			}
		}
	}

	return 0L;
}

// /------------------------------------------------------------
// | FMTHMethod
// | 
// | Class  Name: CBaseToolbarView
// | Method Name: ModifyToolBarViewForCompoundKeys
// | 
// | Return Type: void
// | 
// | Parameters:  void
// | 
// | Purpose: Modification de fmtoolbarview pour les clés composées 
// | Les clés composées peuvent afficher jusqu'à MAXINDEX - 1 caractères.
// | On modifie la taille du fmedit, ensuite on ajuste la taille de la toolbar
// | et on la repositionne
//  ------------------------------------------------------------

void CBaseToolbarView::ModifyToolBarViewForCompoundKeys()
{
	CRect rectView, rectToolBar, rectFmEdit;
	int nbCharToDisplay, newFmEditWidth, newToolBarWidth, toolBarLeft, spaceBetweenComponants, toolBarRightMargin;

	//on récupère les emplacements des composants
	GetWindowRect(&rectView);
	ScreenToClient(&rectView);
	m_editKey.GetWindowRect(&rectFmEdit);
	ScreenToClient(&rectFmEdit);
	m_wndToolBar.GetWindowRect(&rectToolBar);
	ScreenToClient(&rectToolBar);
	spaceBetweenComponants	= rectToolBar.left - rectFmEdit.right;
	toolBarRightMargin		= rectView.right - rectToolBar.right;


	//on calcule les nouvelles largeurs et positions
	nbCharToDisplay		= (Des_option_display.nb_compound_key_chars > 0 && Des_option_display.nb_compound_key_chars < MAXINDEX) ? Des_option_display.nb_compound_key_chars : LENGTH_CLE -1; 
	newFmEditWidth		= FM_EDIT_MIN_WIDTH + nbCharToDisplay * FM_CHAR_WIDTH;
	newToolBarWidth		= rectView.Width() - rectFmEdit.left - newFmEditWidth - spaceBetweenComponants- toolBarRightMargin;
	toolBarLeft			= rectFmEdit.left + newFmEditWidth + spaceBetweenComponants;
	

	//On applique les modifications
	//resize fmedit
	m_editKey.SetWindowPos(NULL, 0, 0, newFmEditWidth, rectFmEdit.Height(), SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
	//move and resize toolbar
	m_wndToolBar.SetWindowPos(NULL, toolBarLeft, rectToolBar.top, newToolBarWidth, rectToolBar.Height(), SWP_NOOWNERZORDER|SWP_NOZORDER);
}

void CBaseToolbarView::OnDestroy()
{
	CFormView::OnDestroy();
	if(0==m_wndToolBar.DestroyWindow())
	{
		CString szError;
		szError=_T("Failed to destroy m_wndToolbar in CBaseToolbarView::OnDestroy ");
		FMTRACE(Framework, 0, szError);
		FMLOG(szError, eAssertLevel_Fatal);
		#ifdef _DEBUG
			AfxMessageBox(szError);
		#endif
	}
	m_bViewDestroyed=TRUE;
}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: IsCommandInToolbar
// |
// | Return Type: BOOL
// |
// | Parameters:  (UINT nID)
// |
// | Purpose: Returns TRUE if nID is available in the toolbar
// |
//  ------------------------------------------------------------
BOOL CBaseToolbarView::IsCommandInToolbar(UINT nID)
{
	return (m_wndToolBar.CommandToIndex(nID)!=-1);
}

// /------------------------------------------------------------
// | FMTHMethod
// |
// | Class  Name: CBaseToolbarView
// | Method Name: IsFocusInFmedit()
// |
// | Return Type: BOOL
// |
// | Parameters:  none
// |
// | Purpose: returns TRUE if Fmedit or FMBitmapButton has the focus
// |	In that case, OnCmdMsg should not change the focus
//  ------------------------------------------------------------
BOOL CBaseToolbarView::IsFocusInFmedit()
{
	return m_editKey.HasFocus();
}

// /------------------------------------------------------------
// | FMTHMethod
// | 
// | Class  Name: CBaseToolbarView
// | Method Name: IsTemplateDefinitionInvisible
// | 
// | Return Type: bool
// | 
// | Parameters:  int nMenuID
// | 
// | Purpose: returns TRUE if user can't access a template defintion screen  
// |			i.e. if the corresponding definition menu is not visible in its menus
// |			In that case, we hide the back button
//  ------------------------------------------------------------
bool	CBaseToolbarView::IsTemplateDefinitionInvisible(int nMenuID)
{
	bool bRet=false;
	UINT nTemplateDefinitionMenuID=-1;

	switch(nMenuID)
	{	
		case bREPORT_LREPORT_D2:
		case bREPORT_LREPORT_A2:
			nTemplateDefinitionMenuID=bREPORT_LREPORT_D;
			break;
		case bREPORT_CREPORT_D2:
		case bREPORT_CREPORT_A2:
			nTemplateDefinitionMenuID=bREPORT_CREPORT_D;
			break;
		case bOLAP_D2:
		case bOLAP_A2:
			nTemplateDefinitionMenuID=bOLAP_D;
			break;
		case bDDA_D2:
		case bDDA_A2:
			nTemplateDefinitionMenuID=bDDA_D;
			break;
		case ID_PROMO_ANALYZE:
			nTemplateDefinitionMenuID=ID_PROMO_ANALYZE_PARAM;
			break;
		case ID_ANALYZER_LINE_DIRECT_ELEMENT:
		case ID_ANALYZER_LINE_DIRECT_AGGREGATE:
			nTemplateDefinitionMenuID = ID_ANALYZER_LINE_TEMPLATE;
			break;
		case ID_NODE_ATTRIBUTES_EDIT_DIRECT_ELEMENT:
		case ID_NODE_ATTRIBUTES_EDIT_DIRECT_AGGREGATE:
			nTemplateDefinitionMenuID = ID_NODE_ATTRIBUTES_EDIT_TEMPLATE;
			break;
		case bREPORT_LREPORT_D:
		case bREPORT_CREPORT_D:
		case bOLAP_D:
		case bDDA_D:
		case ID_PROMO_ANALYZE_PARAM:
		case ID_ANALYZER_LINE_TEMPLATE:
		case ID_NODE_ATTRIBUTES_EDIT_TEMPLATE:
			nTemplateDefinitionMenuID = nMenuID;
			break;

		case ID_DETAIL_REPORT_DIRECT_ELEMENT:
		case ID_DETAIL_REPORT_DIRECT_AGGREGATE:
			nTemplateDefinitionMenuID = ID_DETAIL_SERIES_REPORT;
			break;
		
		case ID_DDS_DIRECT_ELEMENT:
		case ID_DDS_DIRECT_AGGREGATE:
			nTemplateDefinitionMenuID = ID_DDS;
			break;
	}
	if(-1!=nTemplateDefinitionMenuID)
	{
		CMainFrame* pMainWnd = MyAfxGetMainWnd();
		if(pMainWnd)
		{
			bRet = !pMainWnd->IsCommandInMenu(nTemplateDefinitionMenuID);
			/*
			HMENU hMenu = (HMENU)pMainWnd->SendMessage(RegisterWindowMessage(_T("CNewMenuBar::WM_GETMENU")));
			CNewMenu* pMenu = (CNewMenu *)CMenu::FromHandle(hMenu);

			if(pMenu)
				bRet = (-1==pMenu->GetMenuState(nTemplateDefinitionMenuID,MF_BYCOMMAND));
			*/
		}
	}
	return bRet;
}

// /------------------------------------------------------------
// | FMTHMethod
// | 
// | Class  Name: CBaseToolbarView
// | Method Name: OnCtlColor
// | 
// | Return Type: HBRUSH
// | 
// | Parameters:  CDC* pDC, CWnd* pWnd, UINT nCtlColor
// | 
// | Purpose: 
// | 
//  ------------------------------------------------------------
HBRUSH	CBaseToolbarView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	return ApplyTheme(pDC);
}

void CBaseToolbarView::OnSize(UINT nType, int cx, int cy)
{
	CFormView::OnSize(nType, cx, cy);
	if (m_wndToolBar.GetSafeHwnd())
	{
		CRect rectWindow, rectView;
		GetWindowRect(&rectView);
		m_wndToolBar.GetWindowRect(&rectWindow);
		m_wndToolBar.SetWindowPos(NULL, 0, 0, cx-rectWindow.left+rectView.left-FM_NEW_TOOLBAR_MARGIN, rectWindow.Height(), SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
	}
	// TODO: Add your message handler code here
}

void CBaseToolbarView::OnDraw(CDC* /*pDC*/)
{
// TODO: Add your specialized code here and/or call the base class
// voir : COLORREF CNewMenu::GetMenuBarColor2003() pour récupérer les 2 couleurs du gradient et du theme xp l. 2747
//		  DrawItem_XP_2003
//		  peut etre MeasureItem_WinXP

}

// /------------------------------------------------------------
// | FMTHFunction
// | 
// | Funct  Name: OnCommand
// | 
// | Return Type: BOOl
// | 
// | Parameters: WPARAM wParam, LPARAM lParam
// | 
// | Purpose: la methode à pour but de catcher les messages 
// | 
//  ------------------------------------------------------------

BOOL CBaseToolbarView::OnCommand(WPARAM wParam, LPARAM lParam)
{
	BOOL bRet = FALSE;

	int nCodeID=LOWORD(wParam);;
	CString strFromIDCommand = FMGetIDFromString(nCodeID);

	CMyMDIChildWnd *lParentFrame=(CMyMDIChildWnd *) GetParentFrame();
	CString strFromIDMenu = lParentFrame->GetWindowTitlePerso();

	FM_JOB_BEGIN(FMFormatString(FM_STATIC_LOCALIZED_MSG(ID_FMMSG_BEGIN_COMMAND),strFromIDCommand, strFromIDMenu));


	m_wndToolBar.GetToolBarCtrl().EnableButton(nCodeID,FALSE);
	CTime oStartTime;
	oStartTime = CTime::GetCurrentTime();
	DWORD nStartTickCount = GetTickCount();
	CString strMsg, strStartTime;
	strStartTime.Format(_T("%02d:%02d:%02d"), oStartTime.GetHour(), oStartTime.GetMinute(), oStartTime.GetSecond());
	strMsg.Format(_T("Start Toolbar Command ID:%d;\t\tStart Time:%s"),nCodeID, strStartTime);
	FMLOG(strMsg, eAssertLevel_Info);

	bRet = __super::OnCommand(wParam, lParam);
	WriteRecordForCmd(nCodeID, nStartTickCount, oStartTime);

	FM_JOB_END;

	return bRet;
}

void CBaseToolbarView::WriteRecordForCmd(UINT nRecordID, DWORD nStartTickCount, CTime oStartTime)
{
	CTime oEndTime;
	oEndTime = CTime::GetCurrentTime();
	DWORD nEndTickCount = GetTickCount();

	CString strCmd;
	switch(nRecordID)
	{
	case ID_SAVE:
		strCmd = _T("Save");
		break;
	case ID_CREATE:
		strCmd = _T("Create");
		break;
	case ID_DELETE:
		strCmd = _T("Delete");
		break;
	case ID_DUPLICATE:
		strCmd = _T("Duplicate");
		break;
	case ID_GOTO_DDA:
		strCmd = _T("Goto DDA");
		break;
	case ID_RUN:
		strCmd = _T("Run");
		break;
	case ID_GRAPH_CALCULATE:
		strCmd = _T("Calculate");
		break;
	case ID_ESC:
		strCmd = _T("Esc");
		break;
	case ID_REFRESH:
		strCmd = _T("Refresh");
		break;
	case ID_PRINT:
		strCmd = _T("Print");
		break;
	case ID_RCDINFO:
		strCmd = _T("Record Info");
		break;
	case ID_GOTO_NEXT:
		strCmd = _T("Goto Next");
		break;
	default:
		strCmd.Format(_T("%d"), nRecordID);
		break;
	}

	
	CString strStartTime, strEndTime, strDuration;
	strStartTime.Format(_T("%02d:%02d:%02d"), oStartTime.GetHour(), oStartTime.GetMinute(), oStartTime.GetSecond());
	strEndTime.Format(_T("%02d:%02d:%02d"), oEndTime.GetHour(), oEndTime.GetMinute(), oEndTime.GetSecond());
	//calculate duration
	CTimeSpan oDuration = oEndTime - oStartTime;
	DWORD nDurTickCount = nEndTickCount - nStartTickCount;
	strDuration.Format(_T("%02d:%02d:%02d  %d ms"),oDuration.GetHours(),oDuration.GetMinutes(), oDuration.GetSeconds(),nDurTickCount);

	CString strMsg;
	strMsg.Format(_T("Toolbar Command:%s;\t\tStart Time:%s;\t\tEnd Time:%s;\t\tDuration:%s"),strCmd, strStartTime, strEndTime,strDuration);
	FMLOG(strMsg, eAssertLevel_Info);
}

BOOL CBaseToolbarView::IsCommandEnable( UINT nID )
{
	return m_wndToolBar.GetToolBarCtrl().IsButtonEnabled(nID);
}

void CBaseToolbarView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
	SaveFocusControl();
}

int CBaseToolbarView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
	CWnd* pWnd = GetFocus();
	if(pWnd != NULL)
	{
		CMySpreadWnd* pSpread = NULL;
		if(pWnd->IsKindOf(RUNTIME_CLASS(CMySpreadWnd)))
		{
			pSpread = (CMySpreadWnd*)pWnd;
		}
		if(pWnd->GetParent()->IsKindOf(RUNTIME_CLASS(CMySpreadWnd)))
		{
			pSpread = (CMySpreadWnd*)(pWnd->GetParent());
		}
		if(pSpread != NULL)
		{
			if (pSpread->GetEditMode())
			{
				pSpread->SetEditMode(FALSE);
			}
		}
	}
	return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
}

void CBaseToolbarView::OnEditGetFocus()
{
	CMyMDIChildWnd* aParentFrame = (CMyMDIChildWnd*)GetParentFrame();
	if(aParentFrame != NULL)
	{
		aParentFrame->m_bToolBarFocus = TRUE;
	}
}

void CBaseToolbarView::OnEditLostFocus()
{
	CMyMDIChildWnd* aParentFrame = (CMyMDIChildWnd*)GetParentFrame();
	if(aParentFrame != NULL)
	{
		CWnd* pWnd = CWnd::GetFocus();
		if( pWnd!=NULL && pWnd!=this && !IsChild(pWnd) )
		{
			if( aParentFrame->IsChild(pWnd) || aParentFrame->HasFloatingWnd(pWnd) )
			{
				aParentFrame->m_bToolBarFocus = FALSE;
			}
		}
	}
}

void CBaseToolbarView::OnNavigationFinish()
{
	m_editKey.SetFocusInEdit();
}

int CBaseToolbarView::CanSendWebURLEmail( int nMenuID )
{
	switch(nMenuID)
	{
	case ID_DDA_D:
	case ID_REPORT_LREPORT_D:
	case ID_REPORT_CREPORT_D:
	case ID_DRP_EDITDRP:
	case ID_DRP_EDITDRP2:
	case ID_DRP_EDITDRP3:
	case ID_DRP_EDITDRP4:
	case ID_DRP_EDITDRP_ALL_SIMPLE:
	case ID_DRP_EDITDRP_ALL_SIMPLE2:  
	case ID_DRP_EDITDRP_ALL_SIMPLE3:    
	case ID_DRP_EDITDRP_ALL_SIMPLE4: 
		return 1;
	default:
		return 0;
	}
	return 0;
}

int CBaseToolbarView::CanSaveGridLayout( int nMenuID )
{
	//if current user is not exist, don't show layout variant buttons
	DB_ADDR oUser = FMGetRecordDBADDR(USER, g_oFMRDMConfig.GetDBUserID());
	if(oUser == NULL_DBA)
		return 0;

	switch(nMenuID)
	{
	case bOLAP_D2:
	case bOLAP_A2:
	case bOLAP_D:
	case bOLAP_A:
	case ID_ANALYZER_LINE_DIRECT_AGGREGATE :
	case ID_ANALYZER_LINE_DIRECT_ELEMENT :
		return 1;
	default:
		return 0;
	}
	return 0;
}

int CBaseToolbarView::GetBTCountForCalibrateDDA(int nIDToolbar)
{
	int nCount = 0;
	if( nIDToolbar != TOOLBAR_FOR_FORECAST)
		return nCount;
	if(EnableCalibrateDDA())
		nCount = 4;
	return nCount;
}